package com.mes.task.domain;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import org.hibernate.annotations.BatchSize;
import org.hibernate.annotations.ForeignKey;
import org.hibernate.annotations.GenericGenerator;
import org.springframework.context.annotation.Lazy;

import com.mes.common.domain.BasicModel;

/**
 * 
 * @author lcs
 * data 2017-03-25
 *
 */
@Entity()
//@org.hibernate.annotations.Entity(dynamicInsert=true,dynamicUpdate=true)
@Table(name = "T_DEMANDLINKS")
@BatchSize(size=20)
@Lazy(value=true)
//@Cache(usage=CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
public class DemandLink extends BasicModel {
	
	@Id
	@GenericGenerator(name = "uniqueId", strategy = "assigned")
	@Column(name="UNIQUE_ID",length=50)
	private String uniqueId;
	
	@Override
	public String getUuid() {
		return uniqueId;
	}

	@Override
	public void setUuid(String uuid) {
		this.uniqueId = uuid;
	}
	
	public String getUniqueId() {
		return uniqueId;
	}

	public void setUniqueId(String uniqueId) {
		this.uniqueId = uniqueId;
	}

	@Override
	public String toString() {
		return "DemandLink"+this.getUuid();
	}
	
	public final static String DEPENDTYPE = "2"; // ������
	
	@Column(name="PREDUID")
	protected String predDemandUid;
	
	/**
	 * ���Ӷ���ӳ��--successor
	 */
	//many-to-one
	@ForeignKey(name="null")
	@ManyToOne(fetch=FetchType.EAGER)
	@JoinColumn(name="PREDUID",insertable=false,updatable=false)
	protected Demand predDemand;
	
	@Column(name="SUCCUID")
	protected String succDemandUid;
	
	/**
	 * ���Ӷ���ӳ��--successor
	 */
	//many-to-one
	@ForeignKey(name="null")
	@ManyToOne(fetch=FetchType.EAGER)
	@JoinColumn(name="SUCCUID",insertable=false,updatable=false)
	protected Demand succDemand;
	
	@Column(name="LINKQTY",precision=25,scale=6)
	protected Double linkQty;
	
	@Column(name="DEPENDTYPE")
	protected String dependType;
	
	@Column(name="ISINEFFECT")
	protected Long isInEffect;
	
	@Column(name="LOCKLEVEL")
	protected Long lockLevel;
	
	@Column(name="LOCKEXPIREDATE",length=7)
	protected Date lockExpireDate;
	/**
	 * @return the predDemandUid
	 */
	public String getPredDemandUid() {
		return predDemandUid;
	}
	/**
	 * @param predDemandUid the predDemandUid to set
	 */
	public void setPredDemandUid(String predDemandUid) {
		this.predDemandUid = predDemandUid;
	}
	/**
	 * @return the predDemand
	 */
	public Demand getPredDemand() {
		return predDemand;
	}
	/**
	 * @param predDemand the predDemand to set
	 */
	public void setPredDemand(Demand predDemand) {
		this.predDemand = predDemand;
	}
	/**
	 * @return the succDemandUid
	 */
	public String getSuccDemandUid() {
		return succDemandUid;
	}
	/**
	 * @param succDemandUid the succDemandUid to set
	 */
	public void setSuccDemandUid(String succDemandUid) {
		this.succDemandUid = succDemandUid;
	}
	/**
	 * @return the succDemand
	 */
	public Demand getSuccDemand() {
		return succDemand;
	}
	/**
	 * @param succDemand the succDemand to set
	 */
	public void setSuccDemand(Demand succDemand) {
		this.succDemand = succDemand;
	}
	/**
	 * @return the linkQty
	 */
	public Double getLinkQty() {
		return linkQty;
	}
	/**
	 * @param linkQty the linkQty to set
	 */
	public void setLinkQty(Double linkQty) {
		this.linkQty = linkQty;
	}
	/**
	 * @return the dependType
	 */
	public String getDependType() {
		return dependType;
	}
	/**
	 * @param dependType the dependType to set
	 */
	public void setDependType(String dependType) {
		this.dependType = dependType;
	}
	/**
	 * @return the isInEffect
	 */
	public Long getIsInEffect() {
		return isInEffect;
	}
	/**
	 * @param isInEffect the isInEffect to set
	 */
	public void setIsInEffect(Long isInEffect) {
		this.isInEffect = isInEffect;
	}
	/**
	 * @return the lockLevel
	 */
	public Long getLockLevel() {
		return lockLevel;
	}
	/**
	 * @param lockLevel the lockLevel to set
	 */
	public void setLockLevel(Long lockLevel) {
		this.lockLevel = lockLevel;
	}
	/**
	 * @return the lockExpireDate
	 */
	public Date getLockExpireDate() {
		return lockExpireDate;
	}
	/**
	 * @param lockExpireDate the lockExpireDate to set
	 */
	public void setLockExpireDate(Date lockExpireDate) {
		this.lockExpireDate = lockExpireDate;
	}
	
	
}
